package example.com.dagger2.subcomponentdemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Random;

import javax.inject.Inject;

import dagger.internal.Preconditions;
import example.com.dagger2.R;

/**
 * Created by Asura on 2016/7/27.
 */
public class ChildFragment extends Fragment {
    @Inject
    Random random;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        ((SecondActivity) activity).getSecondActivityComponent().simpleComponent().inject(this);
        Preconditions.checkNotNull(random);
        Log.i("TAG", "random:" + random);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.child_fragment, container, false);
    }
}
